<%@ page import="java.util.List" %>
<%@ page import="net.zjitc.domain.Product" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/10/19
  Time: 8:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>商品列表</title>
</head>
<body>
<%@include file="top.jsp"%>
<form action="${pageContext.request.contextPath}/addCartServlet" align="center">
    <table border="1" align="center" width="50%">
        <h1>商品</h1><br>
        <c:choose>
            <c:when test="${empty productlist}"><h1 style="color: red">查询不到商品</h1><br></c:when>
            <c:otherwise>
                <tr>
                    <td width="5%">序号</td>
                    <td width="10%">商品名称</td>
                    <td width="5%">价格</td>
                    <td width="2%">操作</td>
                </tr>
            </c:otherwise>
        </c:choose>
        <c:forEach var="product" items="${productlist}" varStatus="status"> <%--begin="1"  end=""  step="0"--%>
                                                                              <%--数据状态--%>   <%--从第几条开始,结束--%>  <%--每隔几行查找--%>
            <c:choose>
                <c:when test="${status.count%2==0}">
                    <tr style="background-color: darkgray">
                        <td>${status.count}</td>
                        <td>${product.pname}</td>
                        <td>${product.shopPrice}</td>
                        <td><a href="${pageContext.request.contextPath}/addCartServlet?pid=${product.pid}">购买</a></td>
                    </tr>
                </c:when>
                <c:otherwise>
                    <tr>
                        <td>${status.count}</td>
                        <td>${product.pname}</td>
                        <td>${product.shopPrice}</td>
                        <td><a href="${pageContext.request.contextPath}/addCartServlet?pid=${product.pid}">购买</a></td>
                    </tr>
                </c:otherwise>
            </c:choose>
        </c:forEach>
    </table>
</form>
<%@include file="foot.jsp"%>
</body>
</html>
